package cn.getech.data.development.controller;

import java.util.Arrays;
import java.util.Map;

import cn.getech.data.development.model.req.realtimequeue.RealtimeQueueListReq;
import cn.getech.data.intelligence.common.validator.group.AddGroup;
import cn.getech.system.center.annotation.SysLog;
import cn.getech.system.center.constant.OperationModulesEnum;
import cn.getech.system.center.constant.OperationTypeEnum;
import cn.getech.system.center.constant.module.ModuleEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import cn.getech.data.development.entity.RealtimeQueueEntity;
import cn.getech.data.development.service.RealtimeQueueService;
import cn.getech.data.intelligence.common.utils.BaseRes;
import cn.getech.data.intelligence.common.utils.DataRes;
import cn.getech.data.intelligence.common.utils.PageRes;
import cn.getech.data.intelligence.common.validator.ValidatorUtils;
import cn.getech.data.intelligence.common.utils.PageUtils2;



/**
 * 调度实时队列
 *
 * @author qiuxinglei
 * @email qiuxinglei@gmail.com
 * @date 2020-09-03 10:57:49
 */
@Api(value="调度实时队列",tags={"调度实时队列"})
@RestController
@RequestMapping("/development/realtimequeue")
public class RealtimeQueueController {
    @Autowired
    private RealtimeQueueService realtimeQueueService;

    /**
     * 列表
     */
    @ApiOperation("列表")
    @PostMapping("/list")
    //@SysLog(value="列表",type= OperationTypeEnum.SELECTCODE, modulesType = OperationModulesEnum.BDPMODELCODE,platformModuleType = ModuleEnum.PROJECT_LIST_MODULE_CODE)
    public PageRes<PageUtils2<RealtimeQueueEntity>> list(@RequestBody RealtimeQueueListReq req){
        ValidatorUtils.validateEntity(req, AddGroup.class);
        PageUtils2<RealtimeQueueEntity> page = realtimeQueueService.queryPage(req);

        return BaseRes.okWithPage(page);
    }


    /**
     * 信息
     */
//    @ApiOperation("信息")
//    @GetMapping("/info/{queueeId}")
    public DataRes<RealtimeQueueEntity> info(@PathVariable("queueeId") Long queueeId){
        RealtimeQueueEntity realtimeQueue = realtimeQueueService.getById(queueeId);

        return BaseRes.okWithData(realtimeQueue);
    }

    /**
     * 保存
     */
//    @ApiOperation("保存")
//    @PostMapping("/save")
    public BaseRes save(@RequestBody RealtimeQueueEntity realtimeQueue){
        realtimeQueueService.save(realtimeQueue);

        return BaseRes.ok();
    }

    /**
     * 修改
     */
//    @ApiOperation("修改")
//    @PostMapping("/update")
    public BaseRes update(@RequestBody RealtimeQueueEntity realtimeQueue){
        ValidatorUtils.validateEntity(realtimeQueue);
        realtimeQueueService.updateById(realtimeQueue);
        
        return BaseRes.ok();
    }

    /**
     * 删除
     */
//    @ApiOperation("删除")
//    @PostMapping("/delete")
    public BaseRes delete(@RequestBody Long[] queueeIds){
        realtimeQueueService.removeByIds(Arrays.asList(queueeIds));

        return BaseRes.ok();
    }

}
